package com.cll.learn.cas.demo02;

/**
 * 描述信息:
 *
 * @author CLL
 * @version 1.0
 * @date 2021/5/15 12:22
 */
public class AtomicStampedReferenceTest {

    public static void main(String[] args) {
        User user = new User(17);

        // 3个线程不间断的检测是否需要充值的账户
        for (int i = 0; i < 3; i++) {
            int stamp = user.getMoney().getStamp();
            System.out.println("<<<=== 初始版本号 = " + stamp);
            new Thread(new RechargeThread(user, stamp)).start();
        }
        Thread thread = new Thread(new ConsumeThread(user));
        thread.start();

        try {
            thread.join();
        } catch (InterruptedException ie) {

        }
    }
}
